package com.gxcc3.ygps.common.core.domain.entity;


import com.gxcc3.ygps.common.core.domain.BaseEntity;
import com.gxcc3.ygps.common.utils.StringUtils;

import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
import java.util.Set;

public class SysCompanyUser extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * userid，雪花id
     */
    private String userId;
    /**
     * 所属企业id
     */
    private String companyId;

    /**
     * 登录账号
     */
    private String username;

    /**
     * 登录密码
     */
    private String password;

    /**
     * 头像地址
     */
    private String avatar;

    /**
     * 最后登录ip
     */
    private String loginIp;

    /**
     * 最后登录时间
     */
    private Date loginDate;


    /** 密码最后更新时间 */
    private Date pwdUpdateDate;

    /**
     * 企业所属监管id
     */
    private Long deptId;

    /**
     * 企业所属监管
     */
    private String deptName;


    /**
     * 所属企业
     */
    private String companyName;

    /**
     * 所属企业信用代码
     */
    private String uniformCode;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 用户状态
     */
    private String status;

    /**
     * 昵称
     */
    private String nickName;

    /**
     * 删除标志 0正常，2删除
     */
    private String delFlag;


    /**
     * 用户所有用的roleKey列表
     */
    private String roleKeys;

    /** 角色对象 */
    private List<SysCompanyRole> roles;

    /** 角色组 */
    private Long[] roleIds;


    public SysCompanyUser() {
    }

    public SysCompanyUser(String userId) {
        this.userId = userId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getUserId() {
        return userId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    @NotBlank(message = "登录账号不能为空")
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }


    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public Date getPwdUpdateDate() {
        return pwdUpdateDate;
    }

    public void setPwdUpdateDate(Date pwdUpdateDate) {
        this.pwdUpdateDate = pwdUpdateDate;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public String getUniformCode() {
        return uniformCode;
    }

    public void setUniformCode(String uniformCode) {
        this.uniformCode = uniformCode;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }


    @NotBlank(message = "账号状态不能为空")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getRoleKeys() {
        return roleKeys;
    }

    public void setRoleKeys(String roleKeys) {
        this.roleKeys = roleKeys;
    }

    public boolean isAdmin()
    {
        return isAdmin(this.roleKeys);
    }

    public static boolean isAdmin(String roleKeys)
    {
        return StringUtils.containsAnyIgnoreCase(roleKeys,"admin");
    }

    public List<SysCompanyRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysCompanyRole> roles) {
        this.roles = roles;
    }


    public Long[] getRoleIds()
    {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds)
    {
        this.roleIds = roleIds;
    }
}
